<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        div{
            width: 100px;
            height: 100px;
            border: 1px solid red;
            position: fixed;
            background: red;
            border-radius: 50%;
        }
        .div{
            width: 100px;
            height: 100px;
            background: green;
            position: relative;
            top: 200px;
            left: 80px;
            border-radius: 0;
        }
    </style>
</head>
<body>
    <div class="asd"></div>
    <div class="div"></div>
</body>
</html>
<script src="../day01/js/lodash.js"></script>
<script src="../案例/随机颜色.js"></script>
<script>
    const asd = document.querySelector('.asd')
    let offsetX = 0
    let offsetY = 0
    const os = e => {
        const x = e.clientX - offsetX
        const y = e.clientY - offsetY
        asd.style.top = y + 'px'
        asd.style.left = x + 'px'
}
    asd.addEventListener('mousedown',f => {
        offsetX = f.offsetX
        offsetY = f.offsetY
        document.addEventListener('mousemove',os)
    })

    document.addEventListener('mouseup',f => {
        document.removeEventListener('mousemove',os)
    })
    asd.addEventListener('dblclick',f => {
        asd.style.background = `${fn1()}`
    })
    // document.addEventListener('mousedown',f1)
    // function f1(){
    //     asd.style.background = 'yellow'
    // }
    // document.addEventListener('mouseup',f2)
    // function f2(){
    //     asd.style.background = 'green'
    // }
    
</script>